{include file=buyer.header.html}
<script>
    var price = {$goods.price};
	//产品数量减1
	function decreaseQuantity(spec_id){
	    var item = $('#input_item_' + spec_id);
	    var orig = parseInt(item.val());
	    if(orig > 0){
	        item.val(orig - 1);
	    }
	}
	//产品数量加1
	function addQuantity(spec_id){
	    var item = $('#input_item_' + spec_id);
	    var orig = parseInt(item.val());
	    var quantity=parseInt($('#quantity').html());
	    var value=orig+1;
	    if(value>quantity){
	    	value=quantity;
	    }
	    item.val(value);
	}
	//字数过滤
	function focusText(obj) {
		$(obj).unbind('input propertychange');
		var temp = '';
		$(obj).bind('input propertychange', function() {
			var val = $(obj).val();
			if (val.length == 500) {
				temp = val;
			}
			if (val.length > 500) {
				$(obj).val(temp);
				window.alert('留言字数超限');
			}
		});
	}
	//显示提示语
	function showTipsPop(o){
		var obj=$(o);
		$('#tips_pop').show();
	}
	//隐藏提示语
	function hideTipsPop(o){
		var obj=$(o);
		$('#tips_pop').hide();
	}

    function updateQuantity(){
        var money = parseFloat($('#goods_money').val());
        var input_item=$('#input_item_1573');
        if(money>0 && parseInt(input_item.val()) == 0)
        {
            input_item.val(1);
        }
    }

	$(function(){
		var goods_money=$('#goods_money'),
			goods_freight=$('#goods_freight'),
			max_money=$('#max_money'),
			max_freight=$('#max_freight');
            //input_item=$('#input_item_1573');
		var add_file=$('#add_file');

		goods_money.bind('blur',function(){
			var _val=$.trim($(this).val());
            if(typeof(goods_freight.val()) == "undefined" || goods_freight.val()=='')
            {
                wl.zWeight(this);
            }
            else
            {
                var freg = /^[0-9]+\d*$|^[1-9]+\d*\.\d{1,3}$|^\d\.\d{1,3}$/;
                if (!freg.test(_val))
                {
                    $(this).val('');
                }
            }

			if(parseFloat(_val)>parseFloat(max_money.html())){
				wl.sConfirm({'info':'输入有误。','cancel':true,'success':function(){
					goods_money.val('');
				}});
			}

            /*if(parseFloat(_val)>0){
                input_item.val(Math.floor(parseFloat(_val)/price));
            }

            if(parseFloat(_val)==0){
                input_item.val(0);
            }*/
		});

		goods_freight.bind('blur',function(){
			var _val=$.trim($(this).val());
			wl.zWeight(this);
			if(parseFloat(_val)>parseFloat(max_freight.html())){
				wl.sConfirm({'info':'输入有误。','cancel':true,'success':function(){
					goods_freight.val('');
				}});
			}

            /*if(parseFloat(goods_money.val()) == 0 || goods_money.val() == '')
            {
                input_item.val(0);
            }*/
		});

		add_file.bind('click',function(){
			var lastLi=$('#morefile').children('li[enctype="file"]:last');
			var len=$('#morefile').children('li[enctype="file"]').length;
			if(len>4){
				add_file.hide();
			}else{
				lastLi.after('<li enctype="file"><input type="file" name="file_'+(len+1)+'" class="file"></li>');
			}
		});

		$('#input_item_1573').bind('keyup',function(){
			var str=$(this).val();
			var freg = /\D*/;
			if (freg.test(str)) {
				$(this).val(0);
				return;
			}
		      var value = parseInt(str);
		      var quantity=parseInt($('#quantity').html());
		      if(value>quantity){
		       	value=quantity;
		       	$(this).val(value);
		      }else if(value<0){
		      	value=0;
		       	$(this).val(value);
		      }
		});

		$('#wlform').validate({
	        errorPlacement: function(error, element) {
	            element.parent().append(error);
	        },
	        rules: {
	            reason:{
	            	required: true
	            },
	            goodsMoney:{
	            	required: true
	            }
	        },
	        messages: {
	            reason:{
	        		required:'请选择退货原因'
	        	},
	        	goodsMoney:{
	            	required: '请填写需退商品金额'
	            }
	        }
	    });

	});
	</script>
<div class="content f-cb"> {include file=path.html}
  {include file=member.menu.buyer.html}
  <!-- 内容右边栏 -->
  <div class="con-r-global">
    <div class="sales-return-progress"></div>
    <div class="sales-return-step01">
      <form action="" method="post" id="wlform"  enctype="multipart/form-data">
        <table class="return-table-title" width="100%">
          <tr>
            <td width="105" class="pdl50"><a href="{jsurl app=goods&id=$goods.goods_id}" title="{$goods.goods_name|escape}" target="_blank"><img src="{$goods.goods_image}" alt="{$goods.goods_name|escape}" width="100" height="100" /></a></td>
            <td><p class="title"><a href="{jsurl app=goods&id=$goods.goods_id}" title="{$goods.goods_name|escape}" target="_blank" class="linkbtn">{$goods.goods_name|escape}</a></p>
              <p>购物数量：<i id="quantity">{$goods.quantity}</i></p>
              <!--{if $goods.specification}--><p>{$goods.specification|escape}</p><!--{/if}--></td>
          </tr>
        </table>
        <table class="return-table-content mb30" width="100%">
          <!--<tr>
            <td width="100" class="pdl50"><i>*</i> 退货商品数：</td>
            <td><ol class="exchange">
                <li> <a href="javascript:decreaseQuantity(1573);"></a> </li>
                <li>
                  <input type="text" name="num" value="1" class="spec_input" readonly id="input_item_1573" />
                <li> <a href="javascript:addQuantity(1573);"></a> </li>
              </ol></td>
          </tr>-->
          <!--{if $returns_type eq 1}-->
          <tr>
            <td  align="right" class="pdl50"><i>*</i> 退款原因：</td>
            <td><select name="reason">
            
                <option value="" checked="checked">请选择退款原因</option>
                <!--{foreach from=$returns_reason.1 item=reason}-->
                <option value="{$reason}">{$reason}</option>
                <!--{/foreach}-->
              </select></td>
          </tr>
          <!--{/if}-->
          <!--{if $returns_type eq 2}-->
          <tr>
            <td align="right" class="pdl50"><i>*</i> 退货原因：</td>
            <td><select name="reason">
            
                <option value="" checked="checked">请选择退货退款原因</option>
                <!--{foreach from=$returns_reason.2 item=reason}-->
                <option value="{$reason}">{$reason}</option>
                <!--{/foreach}-->
              </select></td>
          </tr>
          <!--{/if}-->
          <!--{if $returns_type eq 3}-->
          <tr>
            <td align="right" class="pdl50"><i>*</i> 换货原因：</td>
            <td><select name="reason">
            
                <option value="" checked="checked">请选择换货原因</option>
                <!--{foreach from=$returns_reason.3 item=reason}-->
                <option value="{$reason}">{$reason}</option>
                <!--{/foreach}-->
              </select></td>
          </tr>
          <!--{/if}-->
          <tr>
            <td align="right" class="pdl50">补充说明：</td>
            <td><textarea name="message" placeholder="请您如实填写商品情况，字数在500字以内。" onfocus="focusText(this)"></textarea></td>
          </tr>
          <tr>
            <td align="right" class="pdl50">相关图片：</td>
            <td><ol class="valid-d" id="morefile">
                <li enctype="file">
                  <input type="file" name="file_1" class="file" />
                  <span class="help" onmouseenter="showTipsPop(this)" onmouseleave="hideTipsPop(this)">上传帮助</span> </li>
                <li> <a href="javascript:void(0)" id="add_file" class="addfile">增加图片</a> <a href="javascript:void(0)" id="close_file" class="closefile"></a> </li>
                <li id="tips_pop" class="tips_pop">最多可上传5张图片，每张图片大小不超过500KB，支持jpg，jpeg，png，gif格式文件。</li>
              </ol></td>
          </tr>
          <tr>
            <td align="right" class="pdl50"><i>*</i> 需退商品金额：</td>
            <td><input type="text" name="goodsMoney" class="txt" id="goods_money" />
              <span class="unit">元</span> <span class="note">（最大退款额：<em id="max_money">{$goods.order_goods_amount}</em> 元）</span></td>
          </tr>
          <!--{if $goods.returns_fee gt 0 }-->
          <tr>
            <td align="right" class="pdl50">需退运费：</td>
            <td><input type="text" name="goodsFreight" class="txt" id="goods_freight" />
              <span class="unit">元</span> <span class="note">（最大退款额：<em id="max_freight">{$goods.returns_fee}</em> 元）</span></td>
          </tr>
          <!--{/if}-->
          <tr>
            <td align="center">&nbsp;</td>
            <td class="pb30"><input type="submit" value="提交申请" class="subbtnhs" />
              <input type="button" onclick="javascript:history.go(-1);" value="取消" class="btngray ml10" /></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
{include file=footer.html} 